<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Support\Facades\Log;

class SignCheck
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        //验签
        if(env('ISOPENSIGNCHECK')==0){
            $res = $next($request);
            return $res;
        }
        if(count($request->post())==0){
            $res = $next($request);
            return $res;
        }
        $res=checkformsign($request->post());

        if(!$res){
            return response()->json([
                'code' => 500, 'msg' => '验签失败，非法访问!!'
            ], 500);
        } 

        $res = $next($request);
        return $res;
    }
}
